﻿using System;
using NUnit.Framework;
using Rainbow.ObjectFlow.Engine;

namespace Objectflow.core.tests
{
    public class WhenHandlingWorkflowEngineExceptions
    {
        [Test]
        public void Should_throw_exception()
        {
            var engine = new Dispatcher<string>();
            var operation = new ExceptionOperation();

            var operationWrapper =
                new OperationDuplex<string>(new OperationInvoker<string>(operation));

            Assert.Throws<Exception>(()=> engine.Execute(operationWrapper));
            Assert.That(operation.SuccessResult, Is.EqualTo(false));
        }

        //todo add test to test execution of invoker throws an exception
    }
}
